﻿using System;
using HarmonyLib;
using Helpers;
using MarriageFertility.Actions;
using MarriageFertility.Helpers;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.Actions;
using TaleWorlds.CampaignSystem.CharacterDevelopment;
using TaleWorlds.CampaignSystem.Issues;
using TaleWorlds.CampaignSystem.Party;
using TaleWorlds.CampaignSystem.Settlements;

namespace MarriageFertility.Patches;

public static class FixErrorPatch
{
    [HarmonyPatch(typeof(ChangeKingdomAction), "ApplyInternal")]
    public static class KingdomChangeActionPatch
    {
        public static bool Prefix(Clan clan,
            Kingdom newKingdom,
            ChangeKingdomAction.ChangeKingdomActionDetail detail,
            int awardMultiplier,
            bool byRebellion,
            bool showNotification)
        {
            KingdomAction.ChangeKingdomActionApply(clan, newKingdom, detail, awardMultiplier,
                byRebellion,
                showNotification);
            return false;
        }
    }
    
    
    [HarmonyPatch(typeof(GangLeaderNeedsToOffloadStolenGoodsIssueBehavior), "ConditionsHold")]
    internal class GangLeaderNeedsToOffloadStolenGoodsIssueBehaviorPath
    {
        public static bool Prefix(Hero issueGiver,  Settlement selectedHideout)
        {
            if (issueGiver == null || selectedHideout == null) return false;
            return true;
        }
    }
}